function formatDate(timestamp) {
            var date = new Date(timestamp),
                day = date.getUTCDay() == 0 ? 7 : date.getUTCDay(),
                dayNumber;
            date.setDate(date.getUTCDate() + 4 - day);
            dayNumber = Math.floor((date.getTime() - new Date(date.getUTCFullYear(), 0, 1, -6)) / 86400000);
            return 1 + Math.floor(dayNumber / 7);
        }

$(function() {
    var seriesOptions = [],
        yAxisOptions = [],
        seriesCounter = 0,
        names = ['Active','80443','80','443','22'],
        //'80#443','80','443','22'
        colors = Highcharts.getOptions().colors;

    $.each(names, function(i, name) {

        $.getJSON('chart_global.php?type='+ name.toLowerCase() +'&callback=?',   function(data) {

            seriesOptions[i] = {
                name: name,
                data: data
            };
            seriesCounter++;

            if (seriesCounter == names.length) {
                createChart();
            }
        });
    });
    function createChart() {

        $('#container').highcharts('StockChart', {
            chart: {
                backgroundColor:'transparent'
            },
            title:{
                text:"Port Status"
            },
            rangeSelector: {
                buttons: [ 
                    {
                        type: 'all',
                        text: 'All'
                    }],
                selected: 1
            },

            yAxis: {
                labels: {
                    formatter: function() {
                        return (this.value > 0 ? '+' : '') + this.value + '%';
                    }
                },
                plotLines: [{
                    value: 0,
                    width: 2,
                    color: 'silver'
                }]
            },
            
            plotOptions: {
                series: {
                    compare: 'percent'
                }
            },
            
            tooltip: {
                    formatter: function() {

                        var s='<span style="font-size: 10px">'+Highcharts.dateFormat("%A,%B.%e,%Y",this.points[0].key)+'</span><br/>';
                        var total=0;
                        $.each(this.points, function(i, point) {
                            total+=point.y;
                            s+='<span style="color:'+point.series.color+'">'+point.series.name+'</span>: <b>'+point.y+'</b> ('+Highcharts.numberFormat(point.point.change,2)+'%)<br/>'
                            
                        });
                        return s;
                },
                //pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                valueDecimals: 2
            },
            
            series: seriesOptions
        });
    }

});

$(function() {
    var seriesOptions = [],
        yAxisOptions = [],
        seriesCounter = 0,
        names = ['200','500','400','ErrorStatus','OtherStatuCode'],
        //'80#443','80','443','22'
        colors = Highcharts.getOptions().colors;

    $.each(names, function(i, name) {

        $.getJSON('chart_global.php?type='+ name.toLowerCase() +'&callback=?',   function(data) {

            seriesOptions[i] = {
                name: name,
                marker : {
                    enabled : true,
                    radius : 3
                },
                shadow : true,
                data: data
            };
            seriesCounter++;

            if (seriesCounter == names.length) {
                createChart();
            }
        });
    });
    function createChart() {

        $('#container2').highcharts('StockChart', {
            chart: {
                backgroundColor:'transparent'
            },
            title:{
                text:"Website Status"
            },
            rangeSelector: {
                buttons: [ 
                    {
                        type: 'all',
                        text: 'All'
                    }],
                selected: 1
            },

            yAxis: {
                labels: {
                    formatter: function() {
                        return (this.value > 0 ? '+' : '') + this.value + '%';
                    }
                },
                plotLines: [{
                    value: 0,
                    width: 2,
                    color: 'silver'
                }]
            },
            
            plotOptions: {
                series: {
                    compare: 'percent'
                }
            },
            
            tooltip: {
                 formatter: function() {

                        var s='<span style="font-size: 10px">'+Highcharts.dateFormat("%A,%B.%e,%Y",this.points[0].key)+'</span><br/>';
                        var total=0;
                        $.each(this.points, function(i, point) {
                            total+=point.y;
                            s+='<span style="color:'+point.series.color+'">'+point.series.name+'</span>: <b>'+point.y+'</b> ('+Highcharts.numberFormat(point.point.change,2)+'%)<br/>'
                            
                        });
                        s+="Total:"+total;
                        return s;
                },
                //pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                valueDecimals: 2
            },
            
            series: seriesOptions
        });
    }

});